<template>
	<view class="order-item">
		<view class="order-info">
			<view class="vehicle-info_body">
				<view class="u-flex u-flex-1">
					<view class="picture">
						<image
							src="https://img1.baidu.com/it/u=3291763551,2568659664&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500">
						</image>
					</view>
					<view class="vehicle-info">
						<view class="name">{{getItems.productInfo}}</view>
						<view class="number">×{{getItems.productAmount}}</view>
					</view>
				</view>
				<view class="status">
					{{getStatusLabel(orderType,getItems.status)}}
				</view>
			</view>
			<view class="order-money">
				<text> 实付款： </text>
				<text class="money"> {{getItems.productCurrency}} {{getItems.productSumPrice | thousands}} </text>
			</view>
		</view>
		<!-- 待确认 -->
		<view >
			<u-line color="#F2F2F2" />
			<view class="operation-button">
				<u-button :custom-style="buttonCustomStyle" 
				type="success" class="u-margin-right-16"
				 v-if="getItems.status*1 === 1" shape="circle" size="mini" 
				 @click="handleConfirm">确认</u-button>
				
				<u-button :custom-style="buttonCustomStyle" type="success" shape="circle" size="mini" @click="handleDetails">查看详情</u-button>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		orderType,
		getStatusLabel
	} from "@/utils/status.js";
	export default {
		props: {
			details: {
				type: Object,
				default: () => null
			}
		},
		computed: {
			getItems: {
				get() {
					const item = JSON.parse(JSON.stringify(this.details))
					if (!item) {
						return {}
					}
					return item
				}
			}
		},
		data() {
			return {
				orderType,
				buttonCustomStyle: {
					'color': '#303030',
					'border-radius': '15px',
					'border': '1px solid #D8D8D8',
					'font-size': '13px',
					'background': '#fff',
					'padding': '4px 11px',
					'min-width':'76px'
				},
			}
		},
		methods: {
			handleDeliveryVehicle() {

			},
			handleDeliverySchedule() {
				uni.navigateTo({
					url: '/pages/order/deliverySchedule'
				})
			},
			handleConfirm() {
				uni.navigateTo({
					url: '/pages/order/orderConfirm?id='+this.getItems.id
				})
			},
			handleDetails() {
				uni.navigateTo({
					url: '/pages/order/details?id='+this.getItems.id
				})
			},
			getStatusLabel
		}
	}
</script>

<style scoped lang="less">
	.order-item {
		background: #FFFFFF;
		border-radius: 8px;
		margin-top: 10px;



		.order-info {
			padding-left: 15px;
			padding-right: 15px;
			padding-top: 15px;
			padding-bottom: 10px;

			.vehicle-info_body {
				display: flex;
				justify-content: space-between;

				.picture {
					width: 80px;
					height: 60px;

					&>image {
						width: 100%;
						height: 100%;
					}
				}

				.vehicle-info {
					display: flex;
					flex-flow: column;
					justify-content: space-between;
					height: 60px;
					padding-left: 10px;
					padding-top: 5px;
					padding-bottom: 5px;

					.name {
						color: #202020;
						font-size: 14px;
					}

					.number {
						font-size: 13px;
						color: #919191;
					}
				}

				.status {
					padding-top: 5px;
					color: #0FBD7F;
					font-size: 14px;
				}
			}

			.order-money {
				margin-top: 15px;
				color: #8A8A8A;
				font-size: 13px;
				text-align: right;

				.money {
					color: #F76260 !important;
				}
			}
		}

		.operation-button {
			padding: 10px 15px;
			display: flex;
			justify-content: flex-end;
		}
	}
</style>